package com.service.system;

import com.common.ErrorCodeEnum;
import com.common.emums.DataStatus;
import com.common.exception.BusinessException;
import com.common.utils.StringUtils;
import com.core.springSecurity.common.SecurityUtils;

import com.dao.secondary.system.SystemTestDeviceInfoMapper;
import com.model.domain.system.GetSystemTestDeviceInfoDO;
import com.model.pojo.system.SystemTestDeviceInfo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;



/**
 * @Author: zql
 * @Description: 测试设备信息服务
 * @Data: 2023-12-15
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class SystemTestDeviceInfoService {
    private final SystemTestDeviceInfoMapper systemTestDeviceInfoMapper;

    public List<SystemTestDeviceInfo> getPageList(GetSystemTestDeviceInfoDO getSystemTestDeviceInfoDO){
        PageHelper.clearPage();
        PageHelper.startPage(getSystemTestDeviceInfoDO.getPage(),getSystemTestDeviceInfoDO.getPageSize(),getSystemTestDeviceInfoDO.getSortRow()+getSystemTestDeviceInfoDO.getSortOrder());
        return systemTestDeviceInfoMapper.selectList(getSystemTestDeviceInfoDO);
    }

    public int save(SystemTestDeviceInfo info){
        info.setCreateTime(new Date());
        return systemTestDeviceInfoMapper.insertSelective(info);
    }

    public void saveList(List<SystemTestDeviceInfo> list){
        systemTestDeviceInfoMapper.insertListSelective(list);
    }

    public SystemTestDeviceInfo getById(Long id){
        return systemTestDeviceInfoMapper.selectByPrimaryKey(id);
    }

    public SystemTestDeviceInfo getByDtu(String dtu,Integer type){
        return systemTestDeviceInfoMapper.selectByDtu(dtu,type);
    }
    public void deleteById(long id){
        systemTestDeviceInfoMapper.deleteByPrimaryKey(id);
    }
}
